<!DOCTYPE html>
<html lang="ch" ng-app="typeListModule">
<head>
    <meta charset="UTF-8">
    <title>锦湖日丽</title>
    <link rel="icon" type="image/x-icon" href="images/xlogo.png"/>
    <link rel="stylesheet" type="text/css" href="../css/index.css">
    <link rel="stylesheet" type="text/css" href="../css/listDetail.css">
    <script type="text/javascript" src="/Portal/Mobile/form/jquery-2.1.3.min.js"></script>
    <script src="/Portal/vendor/angular/angular.js"></script>
    <script type="text/javascript">
	    function getQueryString(name) { 
	    	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 
	    	var r = window.location.search.substr(1).match(reg); 
	    	if (r != null) return decodeURI(decodeURI((r[2]))); 
	    	return null; 
	    } 
    
        var typeListModule = angular.module('typeListModule',[]);
        typeListModule.controller('typeListCtrl',  function($scope, $http,$compile){


            $scope.pageSize = 10;

            $scope.pageIndex = 1;

            $scope.maxshowpageitem = 14;




            $scope.init = function() {
                     //先获取分类
                	$scope.GetDatas(1);
            };





            /**
             * 初始化数据处理
             * @param listCount 列表总量
             * @param currentPage 当前页
             */
            $scope.initPage = function(listCount,currentPage){
                var maxshowpageitem = $scope.maxshowpageitem;
                if(maxshowpageitem!=null&&maxshowpageitem>0&&maxshowpageitem!=""){
                    $scope.maxshowpageitem = maxshowpageitem;
                }
                var pagelistcount = $scope.pageSize;
                if(pagelistcount!=null&&pagelistcount>0&&pagelistcount!=""){
                    $scope.pageSize = pagelistcount;
                }
                $scope.pageSize =pagelistcount;
                if(listCount<0){
                    listCount = 0;
                }
                if(currentPage<=0){
                    currentPage=1;
                }

                $scope.initWithUl(listCount,currentPage);
            },
                /**
                 * 初始化分页界面
                 * @param listCount 列表总量
                 */
                $scope.initWithUl = function(listCount,currentPage){
                    var pageCount = 1;
                    if(listCount>=0){
                        var pageCount = listCount % $scope.pageSize>0?parseInt(listCount/$scope.pageSize)+1:parseInt(listCount/$scope.pageSize);
                    }
                    var appendStr = $scope.getPageListModel(pageCount,currentPage);
                    $("#page").html($compile(appendStr)($scope));
                },


                $scope.getPageListModel = function(pageCount,currentPage){
                    var prePage = currentPage-1;
                    var nextPage = currentPage+1;
                    var prePageClass ="pageItem";
                    var nextPageClass = "pageItem";
                    if(prePage<=0){
                        prePageClass="pageItemDisable";
                    }
                    if(nextPage>pageCount){
                        nextPageClass="pageItemDisable";
                    }
                    var appendStr ="";

                    appendStr+="<li><span>每页显示</span><select ng-change='GetDatas(1)'  ng-model= \"pageSize\" ><option value=\"10\" >10</option><option value=\"15\" >15</option>\n" +
                        "            <option value=\"50\" >50</option>\n" +
                        "            <option value=\"100\" >100</option></select><span>条</span></li>";

                    appendStr+="<li class='"+prePageClass+"' page-data='1' page-rel='firstpage' ng-click='GetDatas(1)'>首页</li>";
                    appendStr+="<li class='"+prePageClass+"' page-data='"+prePage+"' page-rel='prepage' ng-click='GetDatas("+(parseInt($scope.pageIndex)==1?1:parseInt($scope.pageIndex-1))+")'>&lt;</li>";
                    var miniPageNumber = 1;
                    if(currentPage-parseInt($scope.pageSize/2)>0&&currentPage+parseInt($scope.pageSize/2)<=pageCount){
                        miniPageNumber = currentPage-parseInt($scope.pageSize/2);
                    }else if(currentPage-parseInt($scope.pageSize/2)>0&&currentPage+parseInt($scope.pageSize/2)>pageCount){
                        miniPageNumber = pageCount-$scope.pageSize+1;
                        if(miniPageNumber<=0){
                            miniPageNumber=1;
                        }
                    }
                    var showPageNum = parseInt($scope.pageSize);
                    if(pageCount<showPageNum){
                        showPageNum = pageCount;
                    }
                    for(var i=0;i<showPageNum;i++){
                        var pageNumber = miniPageNumber++;
                        var itemPageClass = "pageItem";
                        if(pageNumber==currentPage){
                            itemPageClass = "pageItemActive";
                        }

                        appendStr+="<li class='"+itemPageClass+"' page-data='"+pageNumber+"' page-rel='itempage' ng-click='GetDatas("+pageNumber+")'>"+pageNumber+"</li>";
                    }
                    if(showPageNum==0){
                    	appendStr+="<li class='pageItemActive' page-data='1' page-rel='itempage' ng-click='GetDatas(1)'>"+1+"</li>";
                    }
                    appendStr+="<li class='"+nextPageClass+"' page-data='"+nextPage+"' page-rel='nextpage' ng-click='GetDatas("+(parseInt($scope.pageIndex)>=parseInt(pageCount)?parseInt(pageCount):parseInt($scope.pageIndex+1))+")'>&gt;</li>";
                    appendStr+="<li class='"+nextPageClass+"' page-data='"+pageCount+"' page-rel='lastpage' ng-click='GetDatas("+pageCount+")'>尾页</li>";
                    return appendStr;

                };

            //加载通知公告类型
            $scope.LoadNoteDataTypes = function(){
                $http({
                    method:'GET',
                    url:'/GateWay/NoticeController/LoadNoteDataTypes'
                }).success(function(result){
                    if(result.Success){
                        $scope.Types = result.Extend;
                    }else{

                    }
                });
            };

            $scope.ChangeType = function (type) {
                $scope.type = type;
                $scope.GetDatas(1);
                    $(".news-information ul li").removeClass("news-bgc");
                    $(this).addClass("news-bgc");

            };

            $scope.GetDatas = function (pageIndex) {

                $scope.pageIndex = parseInt(pageIndex);

                $scope.LoadNoteData($scope.type);

            };


            //加载通知公告
            $scope.LoadNoteData = function(type){
                $http({
                    method:'GET',
                    url:'/Portal/kumhosunny/gateway/loadNoticeData',
                    params : {
                        "pageIndex" : $scope.pageIndex,
                        "pageSize" : $scope.pageSize,
                        "pageStart" : $scope.pageSize * ($scope.pageIndex - 1),
                        "searchKey" : $scope.searchKey
                    }
                }).success(function(result){
                    if(result.Success) {
                        $scope.datas = result.Extend;
                        $scope.dataCount = result.LoadData;
                        $scope.initPage($scope.dataCount,$scope.pageIndex);
                    } else {

                    }
                });
            };

            $scope.init();
        });



    </script>
    <style>
        #page select{
            width: 60px;
            height: 29px;
            border-radius: 5px;
            font-size: 14px;
            padding-left: 10px;
            margin-top: 4px;
        }
        #page span:first-child {
            margin-right: 5px;
        }
        #page span{
            font-size: 14px;
            margin-left: 5px;
        }
    </style>
</head>
<body ng-controller="typeListCtrl">
<div id="wrapper">
    <div class="header-nav">
    </div>
    <!--导航结束-->
    <!--小标题条star-->
    <div class="news-headline">
        <a class="margin-left-20" href="../index.html"><img src="/Portal/kumhosunny/gateway/images/zhuye.png" class="img-sy">首页</a>
        <span> > </span>
        <a href="#">通知公告</a>
    </div>
    <!--end-->

    <div class="things-content" >
        <div class="information-message" >

            <div class="message-title" ><span  class="margin-left-20">通知公告</span> <div class="search-criteria margin-top-4 float-right" ng-click="GetDatas(1)" style="margin-right: 7px">查询</div>
                <input type="text" class="demo-input" ng-model="searchKey" placeholder="请输入关键词" >
            </div>
            <ul id="demoContent">
                <li ng-repeat="data in datas">
                    <a class="newsTitle" href="/Portal/kumhosunny/gateway/temp/dynamic.html?ObjectId={{data.objectid}}" title="{{data.title}}" target="_blank">{{data.title}}</a>
                    <span>{{data.FinishTime.split(' ')[0]}}</span>
                </li>

            </ul>
            <div class="pageDiv">
            	<ul class="page" id="page"></ul><div></div>
            </div>
        </div>
    </div>
</div>


<script type="text/javascript" src="../js/header.js"></script>
<script type="text/javascript">
    /*导入头部和尾部*/
    $(window).ready(function(){
        $(".header-nav").load("header.html");
    });
</script>
</body>
</html>